using UnityEngine;
using System.Collections;

public class HaulingJob : Job {
	
	GameObject item;
	Item realItem;
	int haulingToX, haulingToY, haulingToZ;
	
	public PlacingJob j;
	Job jobAtEnd;
	
	public HaulingJob(Item nitem, int endX, int endY, int endZ):base((int)nitem.transform.position.x, (int)nitem.transform.position.y, (int)nitem.transform.position.z, 5){
		item = nitem.item;
		realItem = nitem;
		haulingToX = endX; 
		haulingToY = endY;
		haulingToZ = endZ;
	}
	
	public HaulingJob(Item nitem, int endX, int endY, int endZ, Job nendJob):base((int)nitem.transform.position.x, (int)nitem.transform.position.y, (int)nitem.transform.position.z, 5){
		Controller.removeJob(this);
		item = nitem.item;
		realItem = nitem;
		haulingToX = endX; 
		haulingToY = endY;
		haulingToZ = endZ;
		jobAtEnd = nendJob;
	}
	
	public bool workOn(Robot robot){
		//Debug.Log ("At site");
		robot.hauledItem = realItem;
		PlacingJob endJob;
		try {
			endJob = new PlacingJob(haulingToX, haulingToY, haulingToZ, jobAtEnd);
		} catch {
			endJob = new PlacingJob(haulingToX, haulingToY, haulingToZ);
		}
		endJob.percentageComplete = 101;
		robot.assignJob(endJob, true);
		robot.hauling = true;
		j = endJob;
		return false;
	}

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}
}
